<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class AddIndexV1 extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('users', function (Blueprint $table) {
            $table->index('score');
            $table->index('location');
        });

        Schema::table('answers', function (Blueprint $table) {
            $table->index('user_id');
            $table->index('test_id');
        });

        Schema::table('tests', function (Blueprint $table) {
            $table->index('user_id');
            $table->index('submit_at');
        });

        Schema::table('wechat_users', function (Blueprint $table) {
            $table->index('user_id');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('users', function (Blueprint $table) {
            $table->dropIndex(['score']);
            $table->dropIndex(['location']);
        });

        Schema::table('answers', function (Blueprint $table) {
            $table->dropIndex(['user_id']);
            $table->dropIndex(['test_id']);
        });

        Schema::table('tests', function (Blueprint $table) {
            $table->dropIndex(['user_id']);
            $table->dropIndex(['submit_at']);
        });

        Schema::table('wechat_users', function (Blueprint $table) {
            $table->dropIndex(['user_id']);
        });
    }
}
